/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.anote.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JToggleButton;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import org.anote.Note;
import org.tools.ui.helper.LookAndFeel;

/**
 *
 * @author Trilarion 2012
 */
public class NoteExample extends JFrame {
    private static final long serialVersionUID = 1L;

    /**
     * Creates new form NoteExample
     */
    public NoteExample() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        noteDisplayToggleButton = new JToggleButton();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("Note Example");
        setLocationByPlatform(true);
        setResizable(false);

        noteDisplayToggleButton.setText("Show/Hide note");
        noteDisplayToggleButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                noteDisplayToggleButtonActionPerformed(evt);
            }
        });

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(noteDisplayToggleButton)
                .addContainerGap(281, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(noteDisplayToggleButton)
                .addContainerGap(266, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * The show/hide note button was toggled.
     * @param evt
     */
    private void noteDisplayToggleButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_noteDisplayToggleButtonActionPerformed

        // create new Note
        Note note = new Note();
        note.setPosition(200, 200);
        note.setTitle("Untitled");

        NotePanel panel = new NotePanel(note);

        JDialog dlg = panel.getAsDialog();
        dlg.setVisible(true);
    }//GEN-LAST:event_noteDisplayToggleButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        LookAndFeel.setSystemLookAndFeel();
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        System.out.println(supportsWindowDecorations);
        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new NoteExample().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    JToggleButton noteDisplayToggleButton;
    // End of variables declaration//GEN-END:variables
}
